package BehaviorDesignPattern.CommandPattern;

public class TestCommandPattern {
    public static void main(String[] args) {

        Light light=new Light();
        // 创建命令
        Command lightOn = new LightOnCommand(light);
        Command lightOff = new LightOffCommand(light);

        //创建遥控器
        RemoteControl remoteControl = new RemoteControl();

        //执行打开灯光命令
        remoteControl.setCommand(lightOn);
        remoteControl.pressButton();

        //执行关闭灯光命令
        remoteControl.setCommand(lightOff);
        remoteControl.pressButton();

    }
}
